package org.dromara.admin.tenant.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.util.StrUtil;
import org.dromara.admin.tenant.service.AlipayLoginService;
import org.dromara.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 支付宝登录
 *
 * @author Lion Li
 */
@RestController
@RequestMapping("/app/alipay")
public class AlipayLoginController {

    @Autowired
    private AlipayLoginService alipayLoginService;

    /**
     * 登录
     */
    @SaIgnore
    @PostMapping("/login")
    public R<?> login(@RequestBody Map<String, String> params) {
        try {
            Map<String, Object> result = alipayLoginService.login(params);
            return R.ok(result);
        } catch (Exception e) {
            return R.fail("登录失败：" + e.getMessage());
        }
    }
}

